<!-- 订单举报列表 -->
<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="display: flex;justify-content: space-between;">
			<div>
				<p class="text">订单举报列表</p>
			</div>
			<el-form :inline="true">
				<el-form-item>
					<el-button type="primary" @click="Inquire(4)" icon="el-icon-search">自定义查询</el-button>
				</el-form-item>
			</el-form>
		</el-col>
		<!--列表-->
		<el-table :data="UserList" highlight-current-row v-loading="loading" border :cell-style="cellStyle" :header-cell-style="rowClass" style="width: 100%;">
			<el-table-column type="index" align="center" label="ID" width="80"></el-table-column>
			<el-table-column prop="orderNo" align="center" label="订单号"></el-table-column>
			<el-table-column prop="phone" align="center" label="举报人手机号"></el-table-column>
			<el-table-column prop="reportPhone" align="center" label="被举报人手机号"></el-table-column>
			<el-table-column prop="ctime" align="center" label="时间" >
			</el-table-column>
		</el-table>
		<!--批量删除-->
		<el-col :span="24" class="toolbar">
			<el-pagination background layout="total,sizes,prev, pager, next,jumper" @size-change="handleSizeChange" @current-change="handleCurrentChange" :page-size="10" :total="total" style="float:right;">
			</el-pagination>
		</el-col>
		<!-- 自定义查询 cusexcel-->
		<el-dialog title="自定义查询" :visible.sync="cusdialog" width="35%" :before-close="handleClose">
			<el-form :model="cusForm" label-width="125px" ref="cusForm">
				<el-form-item label="举报人手机号" prop="phone">
					<el-input v-model="cusForm.phone" auto-complete="off" placeholder="请输入正确的手机号" style="width: 220px;"></el-input>
				</el-form-item>
				<el-form-item label="被举报人手机号" prop="reportPhone">
					<el-input v-model="cusForm.reportPhone" auto-complete="off" placeholder="请输入正确的账号" style="width: 220px;"></el-input>
				</el-form-item>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="cusdialog = false">取 消</el-button>
				<el-button type="primary"  @click.native="cusSubmit" >查询</el-button>
			</span>
		</el-dialog>
	</section>
</template>
<script>
	import {
		getOrderReport,
		Refreshtoken
	} from '../../../api/api';
	
	export default {
		data() {
			return {
				loading: false,
				UserList: [],
				sels: [],//列表选中列81560
				total: 0,
				page: 1,
				size:10,
				timer: null,
				// 自定义查询
				cusdialog:false,
				cusForm:{
					phone:'',
					reportPhone:''
				}
			}
		},
		mounted() {
			this.getList()
			this.queryInfo();
			this.timer = setInterval(() => {
			   setTimeout(this.queryInfo, 0)
		    }, 600000)
		},
		methods: {
			//获取列表
			getList:function(type){
				var Token = sessionStorage.getItem('Token');
				var timestamp = new Date().getTime();
				var para = {token: Token,curpage:this.page,pagesize:this.size,timestamp: timestamp,};
				this.loading = true;
				getOrderReport(para).then((res) => {
					var res = res.data;
					if (res.code != 0) {
						this.$message({
							message: res.message,
							type: 'error'
						});
					} else {
						this.total = res.data.total;
						this.UserList = res.data.list;
						this.loading = false;
					}
				});
			},
			// 设置定时器
			queryInfo() {
				var Token = sessionStorage.getItem('Token');
				var timestamp = new Date().getTime();
				let para = {token: Token,timestamp: timestamp};
				Refreshtoken(para).then((res) => {
					var res = res.data;
					if (res.code != 0) {
						this.$message({
							message: res.message,
							type: 'error'
						});
					} else {
						this.loading = false;
					}
				});
			},
			Inquire(type){
				if (type == '1') {
					this.status = 1
					this.getList()
				} else if(type == '2'){
					this.status = 2
					this.getList()
				}else if(type == '0'){
					this.status = 0
					this.getList()
				}else if(type =='3'){
					this.status = 3
					this.getList()
				}else if(type == '4'){
					this.cusdialog = true
				}
			},
			selsChange: function (sels) {
				this.sels = sels;
			},
			cellStyle({row, column}){
				return 'text-align:center;padding:5px;';
			},
			rowClass({row, column}){
				return 'text-align:center';
			},
			handleSizeChange(val) {
				this.size = val;
				this.getList();
			},
			handleCurrentChange(currentPage) {
				this.page = currentPage;
				this.getList();
			},
			handleClose(done) {
				this.$confirm('确认关闭？')
					.then(_ => {
						done();
					})
				.catch(_ => {});
			},
			//条件查询
			cusSubmit(){
					// this.$notify({ title: '警告', message: '查询状态状态为必选项', type: 'warning' });
					this.cusdialog = true;
					var Token = sessionStorage.getItem('Token');
					var timestamp = new Date().getTime();
					if (this.cusForm.phone != '') {
						var para = {token: Token,timestamp: timestamp,curpage:this.page,pagesize:this.size,phone:this.cusForm.phone};
					}else if(this.cusForm.reportPhone != '') {
						var para = {token: Token,timestamp: timestamp,curpage:this.page,pagesize:this.size,reportPhone:this.cusForm.reportPhone};
					}
					getOrderReport(para).then((res) => {
						var res = res.data;
						if (res.code != 0) {
							this.$message({
								message: res.message,
								type: 'error'
							});
						} else {
							this.$message({
								message: '查询成功',
								type: 'success'
							});
							this.$refs['cusForm'].resetFields();
							this.cusdialog = false;
							this.total = res.data.total;
							this.UserList = res.data.list;
							this.loading = false;
						}
					});
			},
		},
		
		beforeDestroy() {
		  clearInterval(this.timer);        
		  this.timer = null;
		}
	};
</script>

<style scoped>
.el-button.is-disabled{
	color: #bfcbd9;
	    cursor: not-allowed;
	    background-image: none;
	    background-color: #eef1f6;
	    border-color: #d1dbe5;
}
.el-pagination {
    white-space: nowrap;
    padding: 2px 5px;
    color: #48576a;
}
.el-select .el-input .el-input--suffix .el-input__inner {
    width: 130px !important;
  }  
  
  .demo-table-expand {
  	display: flex;
  	flex-direction: column;
      font-size: 0;
    }
    .demo-table-expand label {
      width: 90px;
      color: #99a9bf;
    }
    .demo-table-expand .el-form-item {
      margin-right: 0;
      margin-bottom: 0;
      width: 50%;
    }
</style>

